﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

// Project defined usings
using Kinect_Interface_Prototype_1.Folder_Control;

namespace Kinect_Interface_Prototype_1.Interface_Design
{
    public class AppDockItem
    {
        public AppType Type { get; set; }
        public String PathToApp { get; set; }
        public PictureBox PictureBox { get; set; }

        public AppDockItem(AppType type, string pathToApp, PictureBox pictureBox)
        {
            Type = type;
            PathToApp = pathToApp;
            PictureBox = pictureBox;      
        }

        public AppDockItem(AppType type, PictureBox pictureBox)
        {
            Type = type;
            PathToApp = String.Empty;
            PictureBox = pictureBox;
        }

        public void onClick(StartupProgram MainProgram)
        {
            if (Type == AppType.SystemApp)
            {
                startProcess(PathToApp);
            }
            else if(Type == AppType.FolderControl)
            {
                FolderControlForm form = new FolderControlForm(MainProgram);
                StartupProgram.FolderControlForms.Add(form);

                form.Show();
            }
            else if (Type == AppType.MediaPlayer)
            {
                MainProgram.MediaPlayer_Open();
            }
            else if (Type == AppType.Keyboard)
            {
                if (MainProgram.VirtualKeyboard_IsKeyboardUp())
                    MainProgram.VirtualKeyboard_Hide();
                else
                    MainProgram.VirtualKeyboard_Show();
            }
        }
                        
        private void startProcess(string processPath)
        {
            if (!String.IsNullOrEmpty(processPath))
            {
                Process process = new Process();
                process.StartInfo.FileName = processPath;
                process.Start();
            }
        }
    }

    public enum AppType
    {
        SystemApp,
        Keyboard,
        MediaPlayer,
        FolderControl
    }

    public class PredefinedApp
    {
        public static List<PredefinedApp> PredefinedApps = new List<PredefinedApp>
        { 
            new PredefinedApp("Microsoft Word", Constants.WordIconImage, PredefinedAppType.MicrosoftWord),
            new PredefinedApp("Microsoft PowerPoint", Constants.PowerPointIconImage, PredefinedAppType.MicrosoftPowerPoint),
            new PredefinedApp("Kinect Keyboard", Constants.KeyboardIconImage, PredefinedAppType.KinectKeyboard),
            new PredefinedApp("Kinect Media Player", Constants.KinectMediaPlayerIconImage, PredefinedAppType.KinectMediaPlayer),
            new PredefinedApp("Kinect Folder Control", Constants.FolderControlIconImage, PredefinedAppType.KinectFolderControl),
            new PredefinedApp("Custom Application", String.Empty, PredefinedAppType.CustomApplication)
        };

        public string Name { get; set; }
        public string ImagePath { get; set; }
        public PredefinedAppType Type { get; set; }

        public PredefinedApp(string name, string imagePath, PredefinedAppType type)
        {
            Name = name;
            ImagePath = imagePath;
            Type = type;
        }
    }

    public enum PredefinedAppType
    {
        MicrosoftWord = 0,
        MicrosoftPowerPoint = 1,
        KinectKeyboard = 2,
        KinectMediaPlayer = 3,
        KinectFolderControl = 4,
        CustomApplication =5
    }
}
